function layerControl(){
	this.defaultAnchor = BMAP_ANCHOR_TOP_LEFT;
	this.defaultOffset = new BMap.Size(15, 197);
}
layerControl.prototype = new BMap.Control();
layerControl.prototype.initialize = function(map){    
	var i = new Image();
	i.src="layer32.png";
	i.onclick=showLayers;
	map.getContainer().appendChild(i);    
	return i;
}
var layerCtrl = new layerControl();
map.addControl(layerCtrl);

function layerSelector(){
	this.defaultAnchor = BMAP_ANCHOR_TOP_LEFT;
	this.defaultOffset = new BMap.Size(50, 0);
}
layerSelector.prototype = new BMap.Control();
var layers={
    //xinye:"新叶",leihuo:"雷火",
pregnant:"孕妇",children:"小孩",cure:"收治",definite:"确诊",
	helped:"已救助",suspected:"高度疑似",possible:"无法排除",contact:"有接触",passaway:"逝者",all:"全部"}

layerSelector.prototype.initialize = function(map){    
	var d = document.createElement("DIV");
	var html=[]
	html.push("<form onchange=layerchange(layer.value)><table>");
	for(var t in layers){
		if(t!="invalidaddress"){
			html.push("<tr><td><input type=radio name=layer id=l_"+t+" value="+t+"><label for=l_"+t+" style='color:"+caseTypes[t].color+"'>"+layers[t]+"</label></td></tr>")
		}
	}
	if(layers["invalidaddress"])html.push("<tr><td>地址不详:"+layers["invalidaddress"]+"</td></tr>")
	html.push("</table></form>");
	d.innerHTML = html.join("");
	with(d.style){
		border="1px solid gray";
		backgroundColor="#eeeeee"
		whiteSpace="nowrap"
		fontSize="medium"
		left="40px";
	}
	map.getContainer().appendChild(d);
	return d;
}

function showLayers(){
	var s = layerSltr
	var c = layerCtrl;
	if(s.isVisible()){
		s.hide()
	}else{
		s.show()
		s.setOffset(new BMap.Size(c.getOffset().width+60,
		c.getOffset().height>150?c.getOffset().height-150:0))
	}
}
var currentLayer="all"
var layerSltr;

function layerchange(type){
	if(!layerSltr){
		layerSltr = new layerSelector();
		map.addControl(layerSltr);
		layerSltr.hide();
	}
	if(!type) type=currentLayer;
	drawMapv(type)
	currentLayer=type;
	layerSltr.hide();
	var t=12;
	if(document.getElementsByClassName("BMap_stdMpCtrl").length>0){
		t=document.getElementsByClassName("BMap_stdMpCtrl")[0].offsetHeight+12;
	}
	layerCtrl.setOffset(new BMap.Size(15, t))
}